package openai

import (
	"github.com/EDDYCJY/go-gin-example/pkg/app"
	"github.com/EDDYCJY/go-gin-example/pkg/openai/aijieyun/pkg/services/aecs"
	"github.com/aliyun/alibaba-cloud-sdk-go/services/ecs"
	"github.com/gin-gonic/gin"
)

func ModifyInstanceAttribute(c *gin.Context) {
	appG := app.Gin{C: c}
	client := aecs.DefaultClient
	request := ecs.CreateModifyInstanceAttributeRequest()

	err := c.BindQuery(request)
	if err != nil {
		appG.ResponseError(-1, err.Error())
	}
	response, err := client.ModifyInstanceAttribute(request)
	if err != nil {
		appG.ResponseError(-1, err.Error())
		return
	}

	// 将响应转换为所需的格式
	responseData, err := parseResponseData(response.GetHttpContentString())
	if err != nil {
		appG.ResponseError(-1, err.Error())
		return
	}
	appG.ResponseSuccess(gin.H{"response": responseData})
}
